package com.xxx.hhh.demo;

import java.io.IOException;
import java.net.*;

/*
发送端

 */
public class ClientDemo {
    public static void main(String[] args) throws IOException {
//        1.创建对象(找码头)
        DatagramSocket ds = new DatagramSocket();
//        2.创建数据对象 DatagramPacket​(byte[] buf, int length, InetAddress address, int port)
        String s = "sssssss";
        byte[] bytes = s.getBytes();
        InetAddress byName = InetAddress.getByName("127.0.0.1");
        int port = 12345;
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length,byName,port);
//        3.发送数据
        ds.send(dp);
//        4.释放资源
        ds.close();


    }
}
